import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { MANAGE_API_BASIC_PATH } from '../../../core/consts';

const api = {
  loadCfg: () => `${MANAGE_API_BASIC_PATH}/sys/cfg/system/get`,
  saveCfg: () => `${MANAGE_API_BASIC_PATH}/sys/cfg/system/save`,
};

export class SystemCfg {
  title: string;
  logoUrl: string;
  imgHost: string;
  systemHost: string;
  telephone: string;
}

@Injectable({
  providedIn: 'root'
})
export class CfgSystemService {

  constructor(private httpClient: HttpClient) {
  }

  loadCfg() {
    return this.httpClient.get<SystemCfg>(api.loadCfg());
  }

  saveCfg(data: SystemCfg) {
    return this.httpClient.post(api.saveCfg(), data);
  }
}
